Start pulling out the configured paths
authorCarlhuda <carlhuda@tilde.io>
Sat, 19 Apr 2014 01:07:51 +0000 (18:07 -0700)
committerCarlhuda <carlhuda@tilde.io>
Sat, 19 Apr 2014 01:07:51 +0000 (18:07 -0700)
src/cargo/core/package.rs
src/cargo/ops/cargo_compile.rs
src/cargo/ops/mod.rs
src/cargo/ops/path_source.rs [deleted file]
src/cargo/util/config.rs

index 7ffd8bfcccee1ba84ace48c0bb49b08715211cd7..dccc6cf58f90140eebb76fa4ecb4e1325819d78a 100644 (file)
@@ -12,7 +12,6 @@ pub struct NameVer {
 
 impl NameVer {
     pub fn new(name: &str, version: &str) -> NameVer {
-        println!("version: {}", version);
         NameVer { name: name.to_owned(), version: semver::parse(version.to_owned()).unwrap() }
     }
 
index 1da10a9f5906b82817ab4d52aeec053e23e39441..1f1eef4c4b5c11efe8192abe938a51e7533e8dd5 100644 (file)
@@ -19,9 +19,11 @@ use std::vec::Vec;
 use serialize::{Decodable};
 use hammer::{FlagDecoder,FlagConfig,FlagConfiguration,HammerError};
 use std::io;
+use std::os;
 use std::io::BufReader;
 use std::io::process::{Process,ProcessExit,ProcessOutput,InheritFd,ProcessConfig};
 use {ToCargoError,CargoResult};
+use util::config::{get_config,all_configs};
 
 #[deriving(Decodable)]
 struct Options {
@@ -34,7 +36,7 @@ impl FlagConfig for Options {
 
 pub fn compile() -> CargoResult<()> {
     let options = try!(flags::<Options>());
-    let manifest_bytes = try!(read_manifest(options.manifest_path).to_cargo_error(~"Could not read manifest", 1));
+    let manifest_bytes = try!(read_manifest(options.manifest_path));
 
     call_rustc(~BufReader::new(manifest_bytes.as_slice()))
 }
@@ -66,6 +68,8 @@ fn exec_tty(program: &str, args: &[~str], input: Option<&mut Reader>) -> CargoRe
 }
 
 fn exec(program: &str, args: &[~str], input: Option<&mut Reader>, configurator: |&mut ProcessConfig|) -> CargoResult<Process> {
+    let paths = get_config(os::getcwd(), "source-paths");
+
     let mut config = ProcessConfig::new();
     config.program = program;
     config.args = args;
@@ -73,7 +77,7 @@ fn exec(program: &str, args: &[~str], input: Option<&mut Reader>, configurator:
 
     println!("Executing {} {}", program, args);
 
-    let mut process = try!(Process::configure(config).to_cargo_error(~"Could not configure process", 1));
+    let mut process = try!(Process::configure(config).to_cargo_error(|e: io::IoError| format!("Could not configure process: {}", e), 1));
 
     input.map(|mut reader| io::util::copy(&mut reader, process.stdin.get_mut_ref()));
 
index 93d60da38d99a2bf3175a2906955de20dfcd8faa..2d9e296a31c24c85f0797c3bc6282bcb9d6ebf56 100644 (file)
@@ -1,4 +1,3 @@
-pub mod path_source;
 pub mod cargo_compile;
 pub mod cargo_read_manifest;
 pub mod cargo_rustc;
diff --git a/src/cargo/ops/path_source.rs b/src/cargo/ops/path_source.rs
deleted file mode 100644 (file)
index 6654c0b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-struct PathSourceOp;
index 9f579fb7a735b33a78dd7ab4e858f76998b2b97f..f97385e2ba37f08d1b10b270078f7e71b1346612 100644 (file)
@@ -1,7 +1,7 @@
 extern crate collections;
 extern crate toml;
 
-use super::super::{CargoResult,ToCargoError};
+use super::super::{CargoResult,ToCargoError,CargoError};
 use std::{io,fmt};
 
 #[deriving(Eq,TotalEq,Clone,Encodable,Decodable)]
@@ -10,9 +10,15 @@ pub enum Location {
     Global
 }
 
+#[deriving(Eq,TotalEq,Clone,Encodable,Decodable,Show)]
+enum ConfigValueValue {
+    String(~str),
+    List(~[~str])
+}
+
 #[deriving(Eq,TotalEq,Clone,Encodable,Decodable)]
 pub struct ConfigValue {
-    value: ~str,
+    value: ConfigValueValue,
     path: ~str
 }
 
@@ -82,8 +88,15 @@ fn extract_config(file: io::fs::File, key: &str) -> CargoResult<ConfigValue> {
     let path = try!(file.path().as_str().to_cargo_error(~"", 1)).to_owned();
     let mut buf = io::BufferedReader::new(file);
     let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error(~"", 1));
-    let val = try!(try!(root.lookup(key).to_cargo_error(~"", 1)).get_str().to_cargo_error(~"", 1));
-    Ok(ConfigValue{ value: val.to_owned(), path: path })
+    let val = try!(root.lookup(key).to_cargo_error(~"", 1));
+
+    let v = match val {
+        &toml::String(ref val) => String(val.to_owned()),
+        &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()),
+        _ => return Err(CargoError::new(~"", 1))
+    };
+
+    Ok(ConfigValue{ value: v, path: path })
 }
 
 fn extract_all_configs(file: io::fs::File) -> CargoResult<collections::HashMap<~str, ConfigValue>> {
@@ -96,7 +109,8 @@ fn extract_all_configs(file: io::fs::File) -> CargoResult<collections::HashMap<~
 
     for (key, value) in table.iter() {
         match value {
-            &toml::String(ref val) => { map.insert(key.to_owned(), ConfigValue { value: val.to_owned(), path: path.clone() }); }
+            &toml::String(ref val) => { map.insert(key.to_owned(), ConfigValue { value: String(val.to_owned()), path: path.clone() }); }
+            &toml::Array(ref val) => { map.insert(key.to_owned(), ConfigValue { value: List(val.iter().map(|s: &toml::Value| s.to_str()).collect()), path: path.clone() }); }
             _ => ()
         }
     }